package net.yunxinyong.cec.service.impl;

import net.yunxinyong.cec.entity.EcnomicInventoryDetailEntity;
import net.yunxinyong.cec.entity.EcnomicInventoryDetailEntityExample;
import net.yunxinyong.cec.mapper.EcnomicInventoryDetailEntityMapper;
import net.yunxinyong.cec.service.PdfInfoService;
import net.yunxinyong.cec.utils.DownLoadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@Service
public class PdfInfoServiceImpl implements PdfInfoService {

    @Autowired
    private EcnomicInventoryDetailEntityMapper eidem;
    @Override
    public void selectById(HttpServletResponse response, Long id) {
        EcnomicInventoryDetailEntityExample eidee=new EcnomicInventoryDetailEntityExample();
        EcnomicInventoryDetailEntityExample.Criteria criteria = eidee.createCriteria();
        System.out.println(id);
        criteria.andIdEqualTo(id);
        ArrayList<EcnomicInventoryDetailEntity> list = (ArrayList<EcnomicInventoryDetailEntity>)eidem.selectByExample(eidee);

        if(list.size()!=0){
            try {
                DownLoadUtils.download(response,list);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else{
            System.out.println("无数据!");
        }


    }
}
